home *** CD-ROM | disk | FTP | other *** search
- FINDFILEINPATH
-
- ' This function locates a file if it's stored in a directory listed
- ' in the Path environment variable. It returns True (-1) if
- ' successful, False (0) if the file is not found.
-
- Function FindFileInPath% (TypePath$, FileName$)
- PathValue$ = Environ$(TypePath$)
- If Len(PathValue$) = 0 Then Exit Function
- End If
- StartPos% = 1
- If Right$(PathValue$, 1) <> ";" Then
- PathValue$ = PathValue$ + ";"
- End If
- DelimPos% = InStr(StartPos%, PathValue$, ";")
- While DelimPos%
- DirValue$ = Mid$(PathValue$, StartPos%, DelimPos% - StartPos%)
- If DirValue$ <> "" Then
- If Right$(DirValue$, 1) <> "\" Then
- DirValue$ = DirValue$ + "\"
- End If
- If Dir$(DirValue$ + FileName$) <> "" Then
- FileName$ = DirValue$ + FileName$
- FindFileInPath% = -1
- Exit Function
- End If
- End If
- StartPos% = DelimPos% + 1
- DelimPos% = InStr(StartPos%, PathValue$, ";")
- Wend
- End Function
-
-